home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / RPC / XML / status.xpl < prev   
Encoding:
Extensible Markup Language  |  2008-11-04  |  4.5 KB  |  111 lines

  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE methoddef SYSTEM "rpc-method.dtd">
  3. <!--
  4.     Generated automatically by make_method v1.12, Wed Nov  5 03:59:22 2008
  5.  
  6.     Any changes made here will be lost.
  7. -->
  8. <methoddef>
  9. <name>system.status</name>
  10. <version>1.2</version>
  11. <signature>struct</signature>
  12. <signature>struct boolean</signature>
  13. <help>
  14. Report on the various status markers of the server itself. The return value is
  15. a STRUCT with the following members:
  16.  
  17.         Key         Type     Value
  18.  
  19.         host        STRING   Name of the (possibly virtual) host name to which
  20.                              requests are sent.
  21.         port        INT      TCP/IP port the server is listening on.
  22.         name        STRING   The name of the server software, as it identifies
  23.                              itself in transport headers.
  24.         version     STRING   The software version. Note that this is defined as
  25.                              a STRING, not a DOUBLE, to allow for non-numeric
  26.                              values.
  27.         path        STRING   URL path portion, for use when sending POST
  28.                              request messages.
  29.         date        ISO8601  The current date and time on the server, as an
  30.                              ISO 8601 date string.
  31.         date_int    INT      The current date as a UNIX time() value. This is
  32.                              encoded as an INT rather than the dateTime.int
  33.                              type, so that it is readable by older clients.
  34.         started     ISO8601  The date and time when the current server started
  35.                              accepting connections, as an ISO 8601 string.
  36.         started_int
  37.                     INT      The server start-time as a UNIX time() value. This
  38.                              is also encoded as INT for the same reasons as
  39.                              the "date_int" value above.
  40.         total_requests
  41.                     INT      Total number of requests served thus far
  42.                              (including the current one). This will not include
  43.                              requests for which there was no matching method,
  44.                              or HTTP-HEAD requests.
  45.         methods_known
  46.                     INT      The number of different methods the server has
  47.                              registered for serving requests.
  48.  
  49. If this method is called with a single boolean value, that value determines
  50. whether the current call should be counted against the value of the
  51. "total_requests" field. This is also handled at the server level. Setting
  52. this boolean value to a "true" value causes the server (and the resulting
  53. data structure returned) to not count this call. This feature allows external
  54. tools (monitors, etc.) to check the status regularly without falsely running
  55. up the value of "total_requests".
  56. </help>
  57. <code language="perl">
  58. <![CDATA[
  59. #!/usr/bin/perl
  60. ###############################################################################
  61. #
  62. #   Sub Name:       status
  63. #
  64. #   Description:    Create a status-reporting struct and returns it.
  65. #
  66. #   Arguments:      NAME      IN/OUT  TYPE      DESCRIPTION
  67. #                   $srv      in      ref       Server object instance
  68. #                   $no_inc   in      boolean   A true/false value that tells
  69. #                                                 whether to count this call
  70. #                                                 in the total_requests field.
  71. #
  72. #   Returns:        hashref
  73. #
  74. ###############################################################################
  75. sub status
  76. {
  77.     use strict;
  78.  
  79.     my $srv = shift;
  80.     my $no_inc = shift || 0;
  81.  
  82.     my $status = {};
  83.     my $time = time;
  84.     my $URI;
  85.  
  86.     require URI;
  87.  
  88.     $status->{name} = ref($srv);
  89.     $status->{version} = RPC::XML::string->new($srv->version);
  90.     $status->{host} = $srv->host || $srv->{host} || '';
  91.     $status->{port} = $srv->port || $srv->{port} || '';
  92.     $status->{path} = RPC::XML::string->new($srv->path);
  93.     $status->{date} = RPC::XML::datetime_iso8601
  94.         ->new(RPC::XML::time2iso8601($time));
  95.     $status->{started} = RPC::XML::datetime_iso8601
  96.         ->new(RPC::XML::time2iso8601($srv->started));
  97.     $status->{date_int} = $time;
  98.     $status->{started_int} = $srv->started;
  99.     $status->{total_requests} = $srv->requests();
  100.     # In special cases where the call to system.status is not going to incr
  101.     # the total, don't add the extra here, either...
  102.     $status->{total_requests}++ unless $no_inc;
  103.     $status->{methods_known} = scalar($srv->list_methods);
  104.  
  105.     $status;
  106. }
  107.  
  108. __END__
  109. ]]></code>
  110. </methoddef>
  111.